﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title> 
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet"  type="text/css" />
    <link href="../../../Scripts/easyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../../Comm/Gener.js"></script>
    <script src="DDLBar.js" type="text/javascript"></script>
    <script src="../../CCFlowEnum.js" type="text/javascript"></script>
    <script src="../../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <script  type="text/javascript">
        //初始化页面
        $(function () {

            InitBar(DeliveryWay.ByDept);

            var ens = new Entities("BP.WF.Template.NodeDepts");
            ens.Retrieve("FK_Node", GetQueryString("FK_Node"));

            var html = "<table style='width:100%;' >";
            html += "<caption >已经设置的部门,合计:(<font color=red>" + ens.length + "</font>)条</caption>";
            var idx = 0;
            for (var i = 0; i < ens.length; i++) {
                var en = ens[i];

                if (idx == 0)
                    html += "<tr>";

                html += "<td>" + en.FK_DeptText + "</td>";

                idx++;
                if (idx == 4) {
                    idx = 0;
                    html += "</tr>";
                }
            }

            html += "</table>";
            document.getElementById("dept").innerHTML = html;
             
            //根据用户的信息，判断是否启用那个设置工具。
            var user = new WebUser();

            $("#OrgModel").hide();
            $("#AdminModel").hide();

            if (user.No == "admin") {
                /*调用通用的.*/
                $("#AdminModel").show();

            } else {
                /*调用集团模式的.*/
                $("#OrgModel").show();
            }
        });
        //弹出新页面
        function OpenNew() {

            var nodeID = GetQueryString("FK_Node");
            var url = "../../../Comm/RefFunc/Branches.htm?EnName=BP.WF.Template.NodeSheet&Dot2DotEnsName=BP.WF.Template.NodeDepts&Dot2DotEnName=BP.WF.Template.NodeDept&AttrOfOneInMM=FK_Node&AttrOfMInMM=FK_Dept&EnsOfM=BP.Port.Depts&DefaultGroupAttrKey=";
        
            url += url + '&NodeID=' + nodeID + '&PKVal=' + nodeID;

            OpenEasyUiDialogExt(url, "绑定部门", 800, 600, true);
        }
        function OpenOld() {
            var url = "../../../Comm/RefFunc/Dot2DotSingle.htm?EnsName=BP.WF.Template.Selectors&EnName=BP.WF.Template.Selector&AttrKey=BP.WF.Template.NodeDepts";
            var nodeID = GetQueryString("FK_Node");
            url += '&NodeID=' + nodeID + '&ShowWay=None&M=' + Math.random();
            OpenEasyUiDialogExt(url, '绑定部门', 800, 500, true);
        }

        //设置本组织岗位.
        function SetOrgDepts() {
            var user = new WebUser();
            OpenNodDeptGroup(user.FK_Dept);
        }

        //设置集团岗位.
        function SetGroupDepts() {
            var user = new WebUser();
            OpenNodDeptGroup(user.GroupNo);
        }

        function OpenNodDeptGroup(orgNo) {
            var url = "NodeDeptGroup.htm?OrgNo=" + orgNo + "&FK_Node=" + GetQueryString("FK_Node");
            OpenEasyUiDialogExt(url, "绑定部门", 500, 600, true);
        }

        //保存
        function Save() {
 
            var nodeID = GetQueryString("FK_Node");
            var node = new Entity("BP.WF.Node", nodeID);
            node.DeliveryWay = DeliveryWay.ByDept;
            node.Update();
            alert("保存成功.");
        }
    </script>
</head>
<body >
    <div id="bar"> </div>

    <div id="AdminModel">
        <fieldset>
            <legend>设置(超级管理员)</legend>
            <ul>
                <li><a href="javascript:OpenNew()"> 设置/更改部门</a></li>
               <!-- <li><a href="javascript:OpenOld()">设置/更改部门(旧版本)</a></li>-->
               <li >该部门下所有的人员都可以处理该节点的工作。</li>
            </ul>
        </fieldset>
    </div>
    <div id="OrgModel">
        <fieldset>
            <legend>设置（组织管理员）</legend>
            <ul>
                <li><a href="javascript:SetGroupDepts()" >设置集团部门</a> </li>
                <li><a href="javascript:SetOrgDepts()" >设置本组织部门</a> </li>
            </ul>
        </fieldset>
    </div>
   
        <div id="dept"> </div>
         

     
</body>
</html>
